#%RAML 0.8
---
title: SLL Service Catalogue Offers Service
version: 1.0
baseUri: http://localhost:8080/offers/
documentation:
  - title: General API information
    content: TODO! Description of the Offers Service Functions
protocols: [HTTP,HTTPS]
schemas:
    - cvType: !include schema/cvType.json
    - cvTypeList: !include schema/cvTypeList.json
    - iiType: !include schema/iiType.json
    - datePeriod: !include schema/datePeriod.json
    - stringList: !include schema/stringList.json
    - offerUnit: !include schema/offerUnit.json
    - offerUnitList: !include schema/offerUnitList.json
    - productReference: !include schema/productReference.json
    - productRefList: !include schema/productRefList.json
    - productReferenceParam: !include schema/productReferenceParam.json
    - productReferenceParamList: !include schema/productReferenceParamList.json
    - product: !include schema/product.json
    - codeSystemCode: !include schema/codeSystemCode.json
    - codeList: !include schema/codeList.json
    - capacity: !include schema/capacity.json
    - capacityList: !include schema/capacityList.json
    - createOffer: !include schema/createOffer.json
    - unitList: !include schema/unitList.json
    - unit: !include schema/unit.json
    - organisation: !include schema/organisation.json
    - contract: !include schema/contract.json
    - contractList: !include schema/contractList.json
    - address: !include schema/address.json
    - contactPreference: !include schema/contactPreference.json
    - contactPreferenceList: !include schema/contactPreferenceList.json
    - gpsPoint: !include schema/gpsPoint.json
    - streetAddress: !include schema/streetAddress.json


/units:
  displayName: OffersService
  description: Service for managing Offers per Care Unit.
  get:
    responses:
      200:
        description: The requested offers was found and is returned in the body.
        body:
          application/json:
            schema: offerUnitList
            example : |
              {
                "creationTime": 1393305743000,
                "productReferences": [
                  {
                      "capacities": null,
                      "comment": null,
                      "contractedPrice": null,
                      "contractedProduct": false,
                      "product": {
                          "codes": null,
                          "creationTime": null,
                          "description": null,
                          "displayName": null,
                          "name": "62",
                          "status": null,
                          "updateTime": null,
                          "updatedByHsaid": null
                      }
                    },
                    "regionalUnitId": "SE2321000016-116V",
                    "relativeDistinguishedName": null,
                    "unitId": "SE2321000016-116V",
                    "updateTime": 1393305743000
                  }
                ]
              }
  post:
    description: Create a new Offer for a specific care unit.
    body:
      application/json:
        schema: createOffer
        example: |
          {
            "hsaID" : "SE2321000016-1HF3",
            "regionalUnitId" : "126t"
          }
    responses:
      201:
        description: The requested Offer was successfully created
  put:
    description: Update an Offer
    body:
      application/json:
        schema: createOffer
        example: |
          {
            "hsaID" : "SE2321000016-1HF3",
            "regionalUnitId" : "126t"
          }
    responses:
      200:
        description: Update successful.
        body:
          application/json:
            schema: createOffer
            example: |
              {
                "hsaID" : "SE2321000016-1HF3",
                "regionalUnitId" : "126t"
              }
  /{hsaID}:
    description: Service for reading the Offers for a specific care unit HSA-id. TODO! REmove one of this one or /byUnitId?
    uriParameters:
       hsaID:
         displayName: The Hsa-id for the care unit to list offer information for
         type: string
    get:
      description: Reads all Offers belonging to a specific Care Unit
      responses:
        200:
          description: The requested capacity information was found and is returned in the body.
          body:
            application/json:
              schema: offerUnitList
              example : |
                {
                  "hsaID": "SE2321000016-3TNL",
                  "product": [
                      {
                          "capacity": [
                              {
                                  "code": "2",
                                  "codeSystem": "oid.sll.vantetider",
                                  "createdByHsaID": "CREATED",
                                  "creationTime": 1425410281000,
                                  "product": null,
                                  "sourceSystemHsaID": "SOURCE",
                                  "validTo": 1427410800000,
                                  "value": "4"
                              },
                              {
                                  "code": "1",
                                  "codeSystem": "oid.sll.vantetider",
                                  "createdByHsaID": "CREATED",
                                  "creationTime": 1425410242000,
                                  "product": null,
                                  "sourceSystemHsaID": "SOURCE",
                                  "validTo": 1427410800000,
                                  "value": "16"
                              }
                          ],
                          "hsaID": "SE2321000016-1HF3",
                          "name": "40"
                      }
                  ]
    delete:
      description: Delete an offer
      responses:
        204:
          description: Offer was deleted successfully (no content in response body)
    /product/:
      description: Add a Product to a specific care unit
      post:
        queryParameters:
          product:
            description: The Product name to add.
            type: string
        responses:
          201:
            description: The requested Offer was successfully created
    /products/:
      description: Set the entire product list for a specific care unit.
      post:
        queryParameters:
          product:
            description: A comma separated list of product names to set. (RAML doesn't seem to have a way to set this, so it's just a string for now)
            type: string
        responses:
          201:
            description: The requested Offer was successfully created
    /contract/:
      description: Add a Contract to a specific offer
      post:
        queryParameters:
          contract:
            description: The Contract UUID to add to the Offer.
            type: string
        responses:
          201:
            description: The requested Contract was successfully added to the Offer
    /contracts/:
      description: Set the entire contract list for a specific care unit.
      post:
        queryParameters:
          contract:
            description: A comma seperated list of contract UUID:s to set. (RAML doesn't seem to have a way to set this, so it's just a string for now)
            type: string
        responses:
          201:
            description: The requested Contracts were successfully added to the Offer
  
  /byunitids:
    description: List all Offers for an incoming list of Care Unit HSA-id:s
    post:
      body:
        application/json:
          schema: unitList
          example: |
            {
                "units": [
                    {
                        "unitId": "SE2321000016-14VK"
                    },
                    {
                        "unitId": "SE2321000016-3M0N"
                    }
                ]
            }
      responses:
        200:
          description: The requested Offers information was found and is returned in the body.
          body:
            application/json:
              schema: offerUnitList
              example : |
                {
                  {
                    "creationTime": 1393305728000,
                    "productReferences": [
                        {
                            "capacities": null,
                            "comment": null,
                            "contractedPrice": null,
                            "contractedProduct": false,
                            "product": {
                                "codes": null,
                                "creationTime": null,
                                "description": null,
                                "displayName": null,
                                "name": "116",
                                "status": null,
                                "updateTime": null,
                                "updatedByHsaid": null
                            }
                        }
                    ],
                    "regionalUnitId": "SE2321000016-3M0N",
                    "relativeDistinguishedName": null,
                    "unitId": "SE2321000016-3M0N",
                    "updateTime": 1393305728000
                }
                
  /byunitid/{unitId}:
    description: Service for reading the Offers for a specific care unit HSA-id. TODO! REmove one of this one or the Root /{HsaId}?
    uriParameters:
       unitId:
         displayName: The Hsa-id for the care unit to list offer information for
         type: string
    get:
      description: Reads all Offers belonging to a specific Care Unit
      responses:
        200:
          description: The requested capacity information was found and is returned in the body.
          body:
            application/json:
              schema: offerUnitList
              example : |
                {
                  "hsaID": "SE2321000016-3TNL",
                  "product": [
                      {
                          "capacity": [
                              {
                                  "code": "2",
                                  "codeSystem": "oid.sll.vantetider",
                                  "createdByHsaID": "CREATED",
                                  "creationTime": 1425410281000,
                                  "product": null,
                                  "sourceSystemHsaID": "SOURCE",
                                  "validTo": 1427410800000,
                                  "value": "4"
                              },
                              {
                                  "code": "1",
                                  "codeSystem": "oid.sll.vantetider",
                                  "createdByHsaID": "CREATED",
                                  "creationTime": 1425410242000,
                                  "product": null,
                                  "sourceSystemHsaID": "SOURCE",
                                  "validTo": 1427410800000,
                                  "value": "16"
                              }
                          ],
                          "hsaID": "SE2321000016-1HF3",
                          "name": "40"
                      }
                  ]
  /byproductname/{productName}:
    description: Service for reading the Offers for a specific product name.
    uriParameters:
       productName:
         displayName: The name of the product to list offer information for
         type: string
    get:
      description: Reads all Offers belonging to care units that have a specific product names ties to them.
      responses:
        200:
          description: The requested offer information was found and is returned in the body.
          body:
            application/json:
              schema: offerUnitList
              example : |
                {
                  "hsaID": "SE2321000016-3TNL",
                  "product": [
                      {
                          "capacity": [
                              {
                                  "code": "2",
                                  "codeSystem": "oid.sll.vantetider",
                                  "createdByHsaID": "CREATED",
                                  "creationTime": 1425410281000,
                                  "product": null,
                                  "sourceSystemHsaID": "SOURCE",
                                  "validTo": 1427410800000,
                                  "value": "4"
                              },
                              {
                                  "code": "1",
                                  "codeSystem": "oid.sll.vantetider",
                                  "createdByHsaID": "CREATED",
                                  "creationTime": 1425410242000,
                                  "product": null,
                                  "sourceSystemHsaID": "SOURCE",
                                  "validTo": 1427410800000,
                                  "value": "16"
                              }
                          ],
                          "hsaID": "SE2321000016-1HF3",
                          "name": "40"
                      }
                  ]
  /byproductreferences/:
    description: List all Offers for an incoming list of Care Unit HSA-id:s
    post:
      body:
        application/json:
          schema: productReferenceParamList
          example: |
            {
                "prList": [
                    {
                        "productReference": "5"
                    },
                    {
                        "productReference": "6"
                    }
                ]
            }
      responses:
        200:
          description: The requested Offers information was found and is returned in the body.
          body:
            application/json:
              schema: offerUnitList
              example : |
                {
                  {
                    "creationTime": 1393305728000,
                    "productReferences": [
                        {
                            "capacities": null,
                            "comment": null,
                            "contractedPrice": null,
                            "contractedProduct": false,
                            "product": {
                                "codes": null,
                                "creationTime": null,
                                "description": null,
                                "displayName": null,
                                "name": "116",
                                "status": null,
                                "updateTime": null,
                                "updatedByHsaid": null
                            }
                        }
                    ],
                    "regionalUnitId": "SE2321000016-3M0N",
                    "relativeDistinguishedName": null,
                    "unitId": "SE2321000016-3M0N",
                    "updateTime": 1393305728000
                }
  /updatedafter/{timeStamp}:
    uriParameters:
       timeStamp:
         displayName: The timestamp offset formatted like 'yyyyMMddHHmmss'.
         type: string
    get:
      description: Returns unit id's for units where offer has been updated after the given timestamp.
      responses:
        200:
          description: The requested offer information was found and is returned in the body.
          body:
            application/json:
              schema: unitList
              example : |
                {
                  "units": [
                    {
                        "unitId": "SE2321000016-14VK"
                    },
                    {
                        "unitId": "SE2321000016-3M0N"
                    }
                  ]
                }

/contracts:
  displayName: ContractsService
  description: Service for managing Contracts
  get:
    description: List all contracts
    responses:
      200:
        description: The requested contract information was found and is returned in the body.
        body:
          application/json:
            schema: contractList
            example : |
              {
                "contracts": [
                  {
                    "id":
                    {
                      "extension": "7f6c9cc1-7495-4b83-902b-f8e3220984ba",
                      "root": "1.5.8.457.2.2"
                    },
                    "type":
                    {
                      "codeSystem": "1.2.758.9.21.3.1",
                      "code": "45"
                    },
                    "datePeriod":
                    {
                      "start": "1427410800000",
                      "end": "1448552000000"
                    }
                  }
                ]
              }
  post:
    description: Create a new Contract
    body:
      application/json:
        schema: contract
        example: |
          {
            "id":
            {
               "extension": "7f6c9cc1-7495-4b83-902b-f8e3220984ba",
               "root": "1.5.8.457.2.2"
            },
            "type":
            {
              "codeSystem": "1.2.758.9.21.3.1",
              "code": "45"
            },
            "datePeriod":
            {
              "start": "1427410800000",
              "end": "1448552000000"
            }
          }
    responses:
      201:
        description: The requested Contract was successfully created
  put:
    description: Update a Contract
    body:
      application/json:
        schema: contract
        example: |
          {
            "id":
            {
               "extension": "7f6c9cc1-7495-4b83-902b-f8e3220984ba",
               "root": "1.5.8.457.2.2"
            },
            "type":
            {
              "codeSystem": "1.2.758.9.21.3.1",
              "code": "45"
            },
            "datePeriod":
            {
              "start": "1427410800000",
              "end": "1448552000000"
            }
          }
    responses:
      200:
        description: Update successful.
        body:
          application/json:
            schema: contract
            example: |
              {
                "id":
                {
                   "extension": "7f6c9cc1-7495-4b83-902b-f8e3220984ba",
                   "root": "1.5.8.457.2.2"
                },
                "type":
                {
                  "codeSystem": "1.2.758.9.21.3.1",
                  "code": "45"
                },
                "datePeriod":
                {
                  "start": "1427410800000",
                  "end": "1448552000000"
                }
              }
  /{contractId}/:
    uriParameters:
       contractId:
         displayName: The id of the contract to work with.
         type: string
    delete:
      description: Delete a contract
      responses:
        204:
          description: The contract was deleted successfully (no content in response body)